package cn.xzzz2020.XJynWeb.mvc.render.impl;

import cn.xzzz2020.XJynWeb.mvc.RequestProcessorChain;
import cn.xzzz2020.XJynWeb.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;

/**
 * 处理在请求中出现的异常
 * @author xzzz2020
 * @version 1.0
 * @date 2020/9/4 16:31
 */
public class InternalErrorResultRender implements ResultRender {

    private String errorMsg;

    public InternalErrorResultRender(String errorMsg){
        this.errorMsg = errorMsg;
    }

    @Override
    public void render(RequestProcessorChain requestProcessorChain) throws Exception {
        HttpServletResponse response = requestProcessorChain.getResponse();
        //设置状态码500和错误信息
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,errorMsg);
    }
}
